#include <cstring>
#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;

int x;
int y;

int s2i(string steps) {
    unordered_set<char> nums{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    if (steps.length() > 2 || steps.length() == 0) return -1;
    int ans = 0;
    int tag = 1;
    for (int i = steps.length() - 1; i >= 0; i--) {
        if (nums.find(steps[i]) == nums.end()) return -1;
        ans += tag * (steps[i] - '0');
        tag *= 10;
    }
    return ans;
}

void move(char direction, int steps) {
    switch (direction) {
        case 'A':
            x -= steps;
            break;
        case 'S':
            y -= steps;
            break;
        case 'D':
            x += steps;
            break;
        case 'W':
            y += steps;
            break;
        default:
            break;
    }
    return;
}

int main() {
    string s;
    cin >> s;
    string cmd[10000];
    int cur = 0;
    int before = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == ';') {
            cmd[cur++] = s.substr(before, i - before);
            before = i + 1;
        }
    }
    cmd[cur++] = s.substr(before, s.length() - before);

    for (int i = 0; i < cur; i++) {
        if (cmd[i] == "") continue;
        if (cmd[i][0] != 'A' && cmd[i][0] != 'S' && cmd[i][0] != 'D' &&
            cmd[i][0] != 'W')
            continue;
        int steps = s2i(cmd[i].substr(1, cmd[i].length() - 1));
        if (steps == -1) continue;
        move(cmd[i][0], steps);
    }
    cout << x << "," << y << endl;
    return 0;
}